package com.ld.security.common.core.base.service;

import com.ld.security.common.core.base.entity.ELangEntity;
import com.ld.security.common.core.constant.LangConstant;
import com.ld.security.common.core.util.LangUtil;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;


public interface ILangService<E extends ELangEntity> extends ISuperService<E> {

    /**
     * 语言转黄
     * @param obj
     * @param langId
     * @return
     */
    default List<E> langTransform(List<E> obj, String langId){

            //简单语言
            LangConstant langConstant =  LangConstant.valueOf(langId);
            LangUtil.langTransform(obj,langConstant);


        return obj;

    }

    /**
     * 对对象单个转换
     * @param obj
     * @param langId
     * @return
     */
    default E langTransform(E obj, String langId){
        List<E> list =  this.langTransform(Arrays.asList(obj),langId);
        if(list.isEmpty()){
            return null;
        }else {
            return  list.get(0);
        }
    }

}
